#import "ALTextView.h"


@implementation ALTextView

-(void)cursorUpdate:(NSEvent *)event {
	NSPoint locationInWindow = [event locationInWindow];
	NSPoint viewPoint = [self convertPoint:locationInWindow fromView:nil];
	BOOL thereIsAMouseInMe = [self mouse:viewPoint inRect:[self bounds]];
	NSCursor *currentCursor = [self isEditable] && thereIsAMouseInMe ? [NSCursor IBeamCursor] : [NSCursor arrowCursor];
	[currentCursor set];
}

-(void)mouseEntered:(NSEvent *)theEvent {
	[super mouseEntered:theEvent];
	NSCursor *currentCursor = [self isEditable] ? [NSCursor IBeamCursor] : [NSCursor arrowCursor];
	[currentCursor set];
	[[self enclosingScrollView] setDocumentCursor:currentCursor];
}

-(void)mouseExited:(NSEvent *)theEvent {
	[super mouseExited:theEvent];
	[[NSCursor arrowCursor] set];
}

-(void)mouseMoved:(NSEvent *)theEvent {
	[super mouseMoved:theEvent];	
	NSCursor *currentCursor = [self isEditable] ? [NSCursor IBeamCursor] : [NSCursor arrowCursor];
	[currentCursor set];
}

@end
